#2018年省赛-程序设计题 全球变暖
n = int(input())
map = [input() for _ in range(n)]
vis = [[False] * n for _ in range(n)]
dir = [(1, 0), (-1, 0), (0, 1), (0, -1)]

# # BFS解法
# q = []  # 队列
# def bfs():
#     global noHigh
#     while q:
#         x, y = q.pop(0)
#         if (map[x + 1][y] == '#' and map[x - 1][y] == '#'
#             and map[x][y + 1] == '#' and map[x][y - 1] == '#'):
#             noHigh = False
#         for i in range(4):
#             dx, dy = x + dir[i][0], y + dir[i][1]
#             if map[dx][dy] == '#' and not vis[dx][dy]:
#                 vis[dx][dy] = True
#                 q.append([dx, dy])

# DFS解法
s = []  # 栈
def dfs():
    global noHigh
    while s:
        x, y = s.pop()
        if (map[x + 1][y] == '#' and map[x - 1][y] == '#'
            and map[x][y + 1] == '#' and map[x][y - 1] == '#'):
            noHigh = False
        for i in range(4):
            dx, dy = x + dir[i][0], y + dir[i][1]
            if map[dx][dy] == '#' and not vis[dx][dy]:
                vis[dx][dy] = True
                s.append([dx, dy])

ans = 0
for i in range(n):
    for j in range(n):
        noHigh = True
        if map[i][j] == '#' and not vis[i][j]:
            vis[i][j] = True
            #q.append([i, j])
            #bfs()
            s.append([i, j])
            dfs()
            if noHigh:
                ans += 1
print(ans)